(function($) {

	$.fn.spasticNav = function(options) {
	
		options = $.extend({
			overlap : 20,
			speed : 200,
			reset : 50,
			color : '#FFF',
			easing : 'easeOutExpo'
		}, options);
	
		return this.each(function() {
		
		 	var nav = $(this),
		 		currentPageItem = $('#selected', nav),
		 		blob,
		 		reset;
		 		
		 	$('<li id="blob"><i></i></li>').css({
		 		width : currentPageItem.outerWidth(),
		 		height : currentPageItem.outerHeight(),
		 		right : currentPageItem.position().right,
		 		top : currentPageItem.position().top,
		 		backgroundColor : options.color
		 	}).appendTo(this);
		 	
		 	blob = $('#blob', nav);
					 	
			$('li:not(#blob)', nav).hover(function() {
				// mouse over
				$("#blob i").css("display","block");
				$("#selected").find("a").css("color","#FFF");
				clearTimeout(reset);
				blob.animate(
					{
						top : $(this).position().top
					},
					{
						duration : options.speed,
						easing : options.easing,
						queue : false
					}
				);
			}, function() {
				// mouse out	
				reset = setTimeout(function() {
					$("#blob i").css("display","none");

					blob.animate({
						top : currentPageItem.position().top
					}, options.speed,function(){
						$("#selected").find("a").css("color","#313131");
						$('#blob').css("width","266px");
					})
				}, options.reset);
				
			});
		 
		
		}); // end each
	
	};
	$("#nav").delegate("#nav a","mouseenter",function(){
		var tempWidth = parseInt($(this).css("width"))+7;
		$("#blob").css("width",tempWidth+"px");
		$(this).next().css("display","block");
		$(this).css("color","#313131");
	});
	$("#nav").delegate("#nav a","mouseleave",function(){
		$(this).next().css("display","none");
		$(this).css("color","#FFF");
	});
})(jQuery);